package com.um.springboot.starter.service.impl;

import cn.hutool.core.util.StrUtil;
import com.um.springboot.starter.constants.Constants;
import com.um.springboot.starter.core.StringJsonRedisTemplate;
import com.um.springboot.starter.service.ApiPermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 甘天伟
 * @date 2025/3/8
 * 版权所有 广州优匠科技有限公司
 */
@Service
public class ApiPermissionServiceImpl implements ApiPermissionService {

    @Autowired
    StringJsonRedisTemplate redisTemplate;

    /**
     * 加载权限列表到Redis
     *
     * @param userId   用户ID
     * @param permList 菜单列表
     */
    @Override
    public void loadPermissionList(String userId, List<String> permList) {
        if (StrUtil.isBlank(userId)) {
            return;
        }
        redisTemplate.opsForValue().set(Constants.API_PERMISSION + ":" + userId, permList);
    }

}
